﻿#pragma once


#include "math/bMath.h"
#include <d3d11.h>


namespace Base {

	struct VertexLayout {
		// 下面都是逐顶点,一个顶点属性一个buffer
		// pos
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_Pos[] = {
				{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};

		// pos + normal
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_PosNormal[] = {
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};

		// pos + color
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_PosColor[] = {
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
		};

		// pos + tex
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_PosTex[] = {
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }
		};

		// pos + normal + tex
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_PosNormalTex[] = {
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 2, 0 , D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};

		// pos + normal +  color + tex
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_PosNormalColorTex[] = {
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 1, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0 , D3D11_INPUT_PER_VERTEX_DATA, 0 },
			{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 3, 0 , D3D11_INPUT_PER_VERTEX_DATA, 0 },
		};


		//-----------------------------------------------
		// Instance  
		// pos + world
		constexpr static D3D11_INPUT_ELEMENT_DESC Layout_Instance_Pos[] = {
			{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },

			// InputSlot  对应 InstanceVertexIn 里面 worldMat 的位置索引
			{ "World", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
			{ "World", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, sizeof(Vec4), D3D11_INPUT_PER_INSTANCE_DATA, 1 },
			{ "World", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, sizeof(Vec4) * 2, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
			{ "World", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, sizeof(Vec4) * 3, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
		};
	};
}